import React, { useEffect } from 'react'
import { connect } from 'react-redux'
import { MyState } from "../../type/router.d"
import style from "./index.module.scss"
import { bindActionCreators, Dispatch } from "redux"
import * as actions from "../../store/modules/action"
import ArchiveConent from "./archive_conent/index"
import Toc from "../archive_Toc/index"


interface Props {
    detaactArr: any
}
export const ArchiveDetial = (props: Props) => {
    useEffect(() => {
        console.log(JSON.parse(props.detaactArr[0].toc))
    }, [])
    return (
        <div className={style["archive-detail-content"]}>
            <div className={style["archive-detail-share"]}>
                <div className={style["share-item"]}>点赞</div>
                <div className={style["share-item"]}>分享</div>
                <div className={style["share-item"]}>评论</div>
            </div>
            <section className={style["archive-detail-main"]}>
                {/* 文章内容 */}
                <ArchiveConent></ArchiveConent>
            </section>


            <aside className={style["archive-detail-side"]}>
                <Toc toc={JSON.parse(props.detaactArr[0].toc)}></Toc>
            </aside>
        </div>
    )
}

const mapStateToProps = (state: MyState) => ({
    detaactArr: state.detaactArr
})

const mapDispatchToProps = (dispatch: Dispatch) => {
    return bindActionCreators(actions, dispatch)
}

export default connect(mapStateToProps, mapDispatchToProps)(ArchiveDetial)